<?php


if (!defined('IN_ANWSION'))
{
	die;
}

/**
 *  ads 广告  model 层
 * @author LSH  2013-01-11  10:01
 *
 */
class ads_class extends AWS_MODEL
{
	public function get_ads_info_by_type($type)
	{
		$ads_list = $this->fetch_all('ads', "ad_type = " . intval($type));

		$rand = rand(0, count($ads_list));
		return $ads_list[$rand];
	}
	
	public function get_ads_list($where = null,$order = null, $limit = null)
	{
		$ads_list = $this->fetch_all('ads',$where,$order,$limit);
		
		if (!empty($ads_list) || $ads_list != false)
		{
			return $ads_list;
		}
		else
		{
			return array();
		}
		
		
	}
	
	public function edit_ads_info($data)
	{
		if (!isset($data['id']) || $data['id'] == 0 or null)
		{
			return false;
		}
		
		return $this->update('ads', $data, 'id = ' . intval($data['id']));
	}
	
	public function add_ads_info($data)
	{
		$ads_id = $this->insert('ads', $data);
		
		return $ads_id;
	}
	
	public function del_ads_by_id($ads_id)
	{
		return $this->delete('ads', "id = " . intval($ads_id));
	}
}